package com.istock.union.user.translate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.istock.base.export.data.TranslateCallback;
import com.istock.base.spring.SpringContextHolder;
import com.istock.union.user.dao.UserInfoMapper;
import com.istock.union.user.model.UserInfo;
import com.istock.union.user.model.UserInfoExample;

/**
 * 传入用户的loginName列表
 * 得到用户列表
 * @author senvon
 *
 */
public class LoginNameTranslateCallback implements TranslateCallback {

	@Override
	public Map<Object, Object> translate(List codeList) {
		if(codeList != null && codeList.size()>0) {
			UserInfoMapper userInfoMapper = SpringContextHolder.getInstance().getBean(UserInfoMapper.class);
			UserInfoExample example = new UserInfoExample();
			UserInfoExample.Criteria criteria = example.createCriteria();
//			criteria.andLoginNameIn(codeList);
			criteria.andUserNameIn(codeList);
			List<UserInfo> userList = userInfoMapper.selectByExample(example);
			
			Map<Object,Object> result = new HashMap<Object , Object>();
			if(userList != null) {
				for(UserInfo userInfo : userList) {
					result.put(userInfo.getUserName(), userInfo);
				}
			}
			return result;
		}
		return null;
	}

}
